% rebase('layout.tpl', title=title,year=year)

<h2>{{ title }}.</h2>

<div id="alertContainer">

</div>

<form action="" method="POST" class="form-horizontal" role="form">
    <div class="form-group">
        <legend>请配置Redis信息</legend>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">域名</label>
        <div class="col-sm-6">
            <input type="hidden" value="{{ model.Redis_Id }}" name="Redis_Id" id="hfRedis_Id">
            <input type="text" class="form-control" placeholder="DomainName" value="{{ model.DomainName }}" name="DomainName" id="txtDomainName">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">IP地址</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" placeholder="IPAddress" value="{{ model.IPAddress }}" name="IPAddress" id="txtIPAddress">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" placeholder="Username" value="{{ model.Username }}" name="Username" id="txtUsername">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">Note</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" value="{{ model.Note }}" name="note" id="txtNote">
        </div>

    </div>
    <div class="form-group">
        <div class="col-sm-6 col-sm-offset-2">
            <button type="submit" class="btn btn-primary" id="btnSave">保存</button>
        </div>
    </div>
</form>

<script src="/static/scripts/sys.js"></script>
<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function (event) {
            // 阻止默认的表单请求
            event.preventDefault();

            $.ajax({
                type: "post",
                url: "/redis/update",
                data: {
                    Redis_Id: $("#hfRedis_Id").val(),
                    DomainName: $("#txtDomainName").val(),
                    IPAddress: $("#txtIPAddress").val(),
                    Username: $("#txtUsername").val(),
                    Note: $("#txtNote").val(),
                    Used: false
                },
                dataType: "json",
                success: function (data) {
                    if (data.state == 0) {
                        // 显示消息栏
                        bs_alert_Info(data.msg);
                    }
                }
            });
        });

    });
</script>